﻿// 2025/10/11: 首个版本

using System;
using ASEva;
using ASEva.UIAvalonia;
using ASEva.Utility;

namespace CommonSource
{
    partial class LaunchSwitchController : DialogPanel
    {
        public LaunchSwitchController()
        {
            InitializeComponent();
            SetFixMode(350, 120, true);
            language = new LanguageSwitch(this.Resources, AgencyLocal.GetAppLanguage());
            Title = language["title"];

            if (AgencyLocal.ClientSide)
            {
                labelCurrent.Content = language["client"];
                buttonSwitch.Content = language.Format("switch", language["host"]);
                buttonStay.Content = language.Format("stay", language["client"]);
            }
            else
            {
                labelCurrent.Content = language["host"];
                buttonSwitch.Content = language.Format("switch", language["client"]);
                buttonStay.Content = language.Format("stay", language["host"]);
            }

            buttonSwitch.Click += delegate
            {
                RequestSwitch = true;
                Close();
            };

            buttonStay.Click += delegate
            {
                RequestSwitch = false;
                Close();
            };
        }

        public String IconResourceName
        {
            set => Icon = ResourceLoader.Load(value)?.ToAvaloniaWindowIcon();
        }

        public bool? RequestSwitch { get; private set; } = null;

        private LanguageSwitch language;
    }
}